<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改物业合同')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-propertyContract-add" th:object="${propertyContract}">
            <input type="hidden" name="contractId" th:value="*{contractId}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">序号：</label>
                <div class="col-sm-8">
                    <input name="num" class="form-control" type="text" th:value="*{num}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">部门：</label>
                <div class="col-sm-8">
                    <input name="department" class="form-control" type="text" th:value="*{department}" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">合同编号：</label>
                <div class="col-sm-8">
                    <input name="contractNo" class="form-control" type="text" th:value="*{contractNo}" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">合同类型：</label>
                <div class="col-sm-8">
                    <select name="contractType" class="form-control" th:field="*{contractType}">
                        <option value="1">收入</option>
                        <option value="2">支出</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同内容：</label>
                <div class="col-sm-8">
                    <input name="content" class="form-control" type="text" th:value="*{content}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">合同单位：</label>
                <div class="col-sm-8">
                    <input name="company" class="form-control" type="text" th:value="*{company}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">起始日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date" >
                        <input autocomplete="off" type="text" class="time-input form-control" id="startTime" placeholder="请填写日期"  name="startTime" th:value="*{#dates.format(startTime, 'yyyy-MM-dd')}"/>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">结束日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date" >
                        <input autocomplete="off" type="text" class="time-input form-control" id="endTime" placeholder="请填写日期"  name="endTime" th:value="*{#dates.format(endTime, 'yyyy-MM-dd')}"/>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">总价：</label>
                <div class="col-sm-8">
                    <input name="totalPrice" class="form-control" type="text" th:value="*{totalPrice}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label ">状态：</label>
                <div class="col-sm-8">
                    <select name="status" class="form-control" th:field="*{status}">
                        <option value="1">正常</option>
                        <option value="2">到期</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <input name="remark" class="form-control" type="text" th:value="*{remark}">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "hrm/propertyContract";

        $.validator.addMethod("totalPriceReg",function (value,element) {
            var reg = new RegExp(/^[0-9]+(.[0-9]+)?$/);
            return this.optional(element) || reg.test(value)
        })
        $("#form-propertyContract-add").validate({

            onkeyup:false,
            rules:{
                totalPrice:{
                    totalPriceReg:true
                }
            },
            messages:{
                totalPrice:{
                    totalPriceReg:"请输入正确的总价"
                }
            },
            focusCleanup: true

        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-propertyContract-add').serialize());
            }
        }

    </script>
</body>
</html>